package cn.edu.scau.cmi.zhuanglinting.composite;

import java.awt.Component;
import java.util.ArrayList;

public class Composite1 implements Component1 {
	private ArrayList <Component1> countryList;
	private String voice = "";
	
	public Composite1(){
		countryList = new ArrayList <Component1> ();
		countryList.add(new LeafChina1());
		countryList.add(new LeafEnglish1());
	}
	
	public void add(Component1 country){
		countryList.add(country);
	}
	
	public void remove(Component1 country){
		if(country != null) countryList.remove(country);
	}
	
	public String say() {
		for(int i = 0;i < countryList.size();i++){
			Component1 voicePackage = countryList.get(i);
			voice += voicePackage.say() + "\n";
		}
		return voice;
	}

}
